<template>
	<view class="question-page">
		<!-- #ifdef APP -->
		<u-navbar title="匿名举报" :autoBack="true" :placeholder="true">></u-navbar>
		<!-- #endif -->
		<view class="tips">为了保护你的隐私安全,我们完全匿名举报,请放心填写。</view>
		<view class="contentBox">
			<view class="submit-type">{{type}}</view>
			<view class="image-box">
				<view class="title">图片证据({{length}}/4)</view>
				<view style="flex: 1;">
					<uploadImage @uploadSuccess='uploadSuccess' name="image" :maxCount='6' width="132rpx" height="168rpx">
					</uploadImage>
				</view>
			</view>
			<view class="content-box">
				<view class="title">举报描述</view>
				<view style="flex: 1;">
					<u-textarea class="custom-textarea" v-model="content" placeholder="点击这里填写举报描述" :clearable="true" border="none"
						:maxlength="200" :count="true" confirmType="done" placeholder-style="font-size:26rpx;line-height:1.5;"
						autoHeight></u-textarea>
				</view>
			</view>
			<view class="button-group">
				<view class="button1" @click="$u.throttle(submitInfo,2000)">提交</view>
			</view>
		</view>
		<view style="height: 20rpx;"></view>
	</view>
</template>

<script>
	import uploadImage from '@/components/UploadImage.vue';
	export default {
		data() {
			return {
				type: '',
				content: '',
				images: '',
				user_id: null,
				length: 0
			}
		},
		components: {
			uploadImage: uploadImage
		},
		onLoad(options) {
			if (options) {
				this.type = options.type
				this.user_id = options.user_id
			}
		},
		methods: {
			submitInfo() {
				this.$Api['user'].submitReport({
					type: this.type,
					content: this.content,
					images: this.images,
					to_user_id: this.user_id
				}).then(res => {
					this.$Tips({
						title: '举报成功'
					}, {
						tab: 3,
						url: 1
					})
				})
			},
			uploadSuccess(e) {
				this.images = e.fileList
				if (this.images) {
					this.length = this.images.split(',').length
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.question-page {
		width: 100%;
		min-height: 100vh;
		background-color: #f7f8fa;
		position: relative;

		.tips {
			background: #FEECFF;
			padding: 12rpx 34rpx;
			font-size: 26rpx;
			color: #F169F6;
			text-align: center;
		}

		.contentBox {
			min-height: 80vh;
			margin: 20rpx 34rpx;
			padding: 38rpx 40rpx 38rpx;
			box-shadow: 0rpx 4rpx 32rpx 0rpx #FFF0FD;
			border-radius: 32rpx;
			background: linear-gradient(180deg, #FFDAF5 0%, #FFFFFF 5%);

			.submit-type {
				font-weight: bold;
				font-size: 36rpx;
				color: #323334;
			}

			.content-box,
			.image-box {
				margin-top: 40rpx;

				.title {
					font-size: 28rpx;
					margin: 42rpx 0 20rpx;
				}

				.custom-textarea {
					background-color: #F7F7F7;
					height: 518rpx;
					border-radius: 16rpx;

					::v-deep .u-textarea__count {
						background-color: #F7F7F7 !important;
					}

					::v-deep .u-textarea__field {
						min-height: 100px;
					}
				}
			}

			.button-group {
				.button1 {
					margin: 160rpx auto 0;
					width: 628rpx;
					height: 88rpx;
					font-weight: bold;
					font-size: 30rpx;
					color: #FFFFFF;
					text-align: center;
					line-height: 88rpx;
					background: linear-gradient(135deg, #FE93BF 0%, #A27AFF 100%);
					box-shadow: 0rpx 4rpx 10rpx 0rpx #FDC4FF;
					border-radius: 44rpx;
				}
			}
		}
	}
</style>